<template>
    <view>
			<u-navbar leftIconColor="#fff" title="合作加盟" @rightClick="rightClick" :autoBack="true">
			</u-navbar>
        <form @reset="formReset" @submit="formSubmit" :reportSubmit="true">
            <view class="container"   :style="{marginTop: top + 20 + 'px'}">
                <!-- <view class="head" :style="'background:' + color">
                    <text>{{ system.rz_title }}</text>
                    <text>申请表</text>
                </view>
                <view class="pt_jj">
                    <rich-text :nodes="system.rz_ms"></rich-text>
                </view> -->
                <view class="process">
                    <!-- <view>加入{{ system.rz_title }}，只需3步</view> -->
										<view class="title">
											加盟流程
										</view>
                    <view class="rzlc flex-row flex-x-center" style="flex-direction: column;width: 90%;margin: 20rpx auto;">
                        <view class="rzitem" style="display: flex;">
                            <!-- <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/shenq.png"></image> -->
                            <image src="/static/ymq_canyino2o/step.png" style="width: 35rpx;height: 35rpx;"></image>
														<text style="font-weight: bold;color: #4B7BFB;">01</text>
                            <view>申请</view>
                        </view>
                        <!-- <view class="rzitem1">
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/liuc.png"></image>
                        </view> -->
                        <view class="rzitem" style="display: flex;">
                            <!-- <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/shenp.png"></image> -->
														<image src="/static/ymq_canyino2o/step.png" style="width: 35rpx;height: 35rpx;"></image>
														<text style="font-weight: bold;color: #4B7BFB;">02</text>
                            <view>审批</view>
                        </view>
                       <!-- <view class="rzitem1">
                            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/liuc.png"></image>
                        </view> -->
                        <view class="rzitem" style="display: flex;">
                            <!-- <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/hezuo.png"></image> -->
														<image src="/static/ymq_canyino2o/step.png" style="width: 35rpx;height: 35rpx;"></image>
														<text style="font-weight: bold;color: #4B7BFB;">03</text>
                            <view>合作</view>
                        </view>
                    </view>
                </view>
                <button formType="submit" style="background: #4B7BFB;border-radius: 39rpx;">我要合作</button>
            </view>
        </form>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            system: {
                rz_title: '',
                rz_ms: ''
            },

            state: '',
            userInfo: '',
            hasUserInfo: false,
            color: '',
						top: 0
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        var that = this;
        app.globalData.util.request({
            url: 'entry/wxapp/system',
            cachetime: '0',
            success: function (t) {
                that.setData({
                    system: t.data
                });
            }
        });
        console.log(t);
        that.setData({
            state: t.state
        });
				
				this.top = uni.getSystemInfoSync().statusBarHeight + 44
    },
    methods: {
        formSubmit: function (a) {
            var t = uni.getStorageSync('users').id;
            app.globalData.util.request({
                url: 'entry/wxapp/AddFormId',
                cachetime: '0',
                data: {
                    user_id: t,
                    form_id: a.detail.formId
                },
                success: function (t) {
                    console.log(t.data);
                }
            });
            var that = this;
            app.globalData.util.request({
                url: 'entry/wxapp/CheckRz',
                cachetime: '0',
                data: {
                    user_id: t
                },
                success: function (t) {
                    console.log(t.data);
                    if (0 != t.data) {
                        if (1 == t.data.state) {
                            uni.showModal({
                                title: '',
                                content: '系统正在审核中'
                            });
                        } else {
                            if (2 == t.data.state) {
                                uni.showModal({
                                    title: '',
                                    content: '您已经合作过了'
                                });
                            } else {
                                if (3 == t.data.state) {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作申请已被拒绝，点击确定进行编辑',
                                        success: function (t) {
                                            if (t.confirm) {
                                                uni.navigateTo({
                                                    url: 'info?form_id=' + a.detail.formId + '&state=3'
                                                });
                                            }
                                        }
                                    });
                                } else {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作已经到期,请联系平台管理员续费'
                                    });
                                }
                            }
                        }
                    } else {
                        uni.navigateTo({
                            url: 'info?form_id=' + a.detail.formId + '&state=' + that.state
                        });
                    }
                }
            });
        },

        getUserInfo: function (t) {
            console.log(t);
            app.globalData.userInfo = t.detail.userInfo;
            this.setData({
                userInfo: t.detail.userInfo,
                hasUserInfo: true
            });
        },

        formReset() {
            console.log('占位：函数 formReset 未声明');
        }
    }
};
</script>
<style>
@import './index.css';
</style>
<style lang="scss" scoped>
	::v-deep .u-status-bar,
	::v-deep .u-navbar__content {
		background-color: #4B7BFB !important;

		.u-navbar__content__title {
			color: #fff !important;
		}
	}
</style>